home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / LibraryOfCongress / Source / misc.c < prev    next >
C/C++ Source or Header  |  1992-08-06  |  3KB  |  81 lines

  1. #include <strings.h>
  2.  
  3. char *CommandHelp[] = {
  4.     "Title search: \"Rowing\" finds all items beginning with \"Rowing...\"\n\
  5. \"Rowing for the hell of it\" finds that book.  Punctuation, upper/lower case, and \"the\", \"an\", \"a\" at the start of a title, will be ignored.",
  6.     "Author search: \"lastname firstname\" as in, \"king stephen\".  Some items have more than one author, or an organization as the author (\"Sierra Club\").",
  7.     "Call number: assigned by libraries to cluster works on similar topics.  Length roughly indicates depth in the topical hierarchy; e.g., \"Z124\" is about printing, and \"Z124.C\" is about the chronology of printing.",
  8.     "ISBN: enter the international standard book number, e.g., \"0-226-13791-0\"",
  9.     "ISSN: enter the international standard serial number, e.g., \"0010-9898\" (and include the hyphen)",
  10.     "LCCN: enter the library of congress card number (8 digits).",
  11.     "OCLC: enter the OCLC, RLIN, or WLN number (8 digits).",
  12.     "Reference number: includes CODEN, Original Study #, Standard Film #, Publisher\"s # for Music, Standard Recording #, Standard Technical Report #, Stock #.  Use spaces and punctuation.",
  13. 0
  14. };
  15.  
  16. char *CommandC = "TACINLOR";
  17.  
  18. int queryType = 0;
  19.  
  20. #define TitleQ  0
  21. #define AuthorQ 1
  22. #define CallQ   2
  23. #define ISBNQ   3
  24. #define ISSNQ   4
  25. #define LCCNQ   5
  26. #define OCLCQ   6
  27. #define RefQ    7
  28.  
  29. void
  30. setFormat(s) char *s; {
  31.     if (!s) return;
  32.     if (strcmp(s,"title")==0)  queryType = TitleQ;  else
  33.     if (strcmp(s,"author")==0) queryType = AuthorQ; else
  34.     if (strcmp(s,"call #")==0) queryType = CallQ;   else
  35.     if (strcmp(s,"ISBN")==0)   queryType = ISBNQ;   else
  36.     if (strcmp(s,"ISSN")==0)   queryType = ISSNQ;   else
  37.     if (strcmp(s,"LCCN")==0)   queryType = LCCNQ;   else
  38.     if (strcmp(s,"OCLC")==0)   queryType = OCLCQ;   else
  39.     if (strcmp(s,"ref #")==0)  queryType = RefQ;    else
  40.     queryType = TitleQ;
  41. }
  42.  
  43. #define Case break; case
  44.  
  45. char *skipsp(), *strippunct(), *stripnondigit();
  46. extern strtolower(), stripnl(), sprintf();
  47.  
  48. char *
  49. fixTitle(s) char *s; {
  50.     strtolower(s);
  51.     if (strncmp(s,"the ",4)==0) s = skipsp(s+4); else
  52.     if (strncmp(s,"an ",3)==0)  s = skipsp(s+3); else
  53.     if (strncmp(s,"a ",2)==0)   s = skipsp(s+2);
  54.     return s;
  55. }
  56.  
  57. char *
  58. cmdHelpText(){
  59.     return CommandHelp[queryType];
  60. }
  61.  
  62. char *
  63. fixQuery(s) char *s; {
  64.     static char t[1024];
  65.     sprintf(t,"%c=",CommandC[queryType]);
  66.     stripnl(s);
  67.     s=skipsp(s);
  68.     switch(queryType){
  69.     Case TitleQ:  strcat(t,fixTitle(s));
  70.     Case AuthorQ: strcat(t,s);
  71.     Case CallQ:   strcat(t,s);   
  72.     Case ISBNQ:   strcat(t,stripnondigit(s));
  73.     Case ISSNQ:   strcat(t,s);
  74.     Case LCCNQ:   strcat(t,s);
  75.     Case OCLCQ:   strcat(t,s);
  76.     Case RefQ:    strcat(t,s);
  77.     }
  78.     return t;
  79. }
  80.  
  81.